<template>
    <div class="quality-overview-container">
        <global-search @submitSearch="submitSearch" class="global-tool-search" :showCoder="false" :showLast="false" @changeCoderList="changeCoderList" @changeDoctorList="changeDoctorList"/>
        <overview-card :cardName="cardName.cardList" :cardData="cardData" listUrlName="OverviewListIndex"/>
        <div class="compare-table">
            <h3>质控效果对比</h3>
            <div class="content">
                <div class="line"></div>
                <div class="line"></div>
                <div class="line"></div>
                <div class="item">
                    <p>修改状态</p>
                    <p>首次</p>
                    <p>末次</p>
                </div>
                <div class="item">
                    <p>国标平均得分</p>
                    <p>{{compareData.firstNationAvgScore}}</p>
                    <div>
                        <p>{{compareData.lastNationAvgScore}}
                            <span v-if="compareData.nationAvgScoreCom !== null"
                                  :class="{'tooltips-red': compareData.nationAvgScoreCom > 0, 'tooltips-blue': compareData.nationAvgScoreCom < 0}">
                                    <i v-if="compareData.nationAvgScoreCom > 0" class="el-icon-top top"></i><i
                                v-if="compareData.nationAvgScoreCom < 0" class="el-icon-bottom bottom"></i>{{Math.abs(getZeroTwoNum(compareData.nationAvgScoreCom))}}
                                </span>
                        </p>
                    </div>
                </div>
                <div class="item">
                    <p>总缺陷病案数</p>
                    <p :class="{pointer: compareData.firstDefect}" @click="toEffectList(false, 4)">{{compareData.firstDefect}}</p>
                    <div>
                        <p :class="{pointer: compareData.lastDefect}" @click="toEffectList(true, 4)">{{compareData.lastDefect}}
                            <span v-if="compareData.defectCom !== null"
                                  :class="{'tooltips-red': compareData.defectCom > 0, 'tooltips-blue': compareData.defectCom < 0}">
                                    <i v-if="compareData.defectCom > 0" class="el-icon-top top"></i><i
                                v-if="compareData.defectCom < 0" class="el-icon-bottom bottom"></i>{{Math.abs(getZeroTwoNum(compareData.defectCom * 100))}}%
                                </span>
                        </p>
                    </div>
                </div>
                <div class="item">
                    <p>编码缺陷病案数</p>
                    <p :class="{pointer: compareData.firstCodingDefect}" @click="toEffectList(false, 5)">{{compareData.firstCodingDefect}}</p>
                    <div><p :class="{pointer: compareData.lastCodingDefect}" @click="toEffectList(true, 5)">{{compareData.lastCodingDefect}}
                        <span v-if="compareData.codingDefectCom !== null"
                              :class="{'tooltips-red': compareData.codingDefectCom > 0, 'tooltips-blue': compareData.codingDefectCom < 0}">
                                    <i v-if="compareData.codingDefectCom > 0" class="el-icon-top top"></i><i
                            v-if="compareData.codingDefectCom < 0" class="el-icon-bottom bottom"></i>{{Math.abs(getZeroTwoNum(compareData.codingDefectCom * 100))}}%
                                </span></p></div>
                </div>
                <div class="item">
                    <p>非编码缺陷病案数</p>
                    <p :class="{pointer: compareData.firstNoneCodingDefect}" @click="toEffectList(false, 6)">{{compareData.firstNoneCodingDefect}}</p>
                    <div><p :class="{pointer: compareData.lastNoneCodingDefect}" @click="toEffectList(true, 6)">{{compareData.lastNoneCodingDefect}}
                        <span v-if="compareData.noneCodingDefectCom !== null"
                              :class="{'tooltips-red': compareData.noneCodingDefectCom > 0, 'tooltips-blue': compareData.noneCodingDefectCom < 0}">
                                    <i v-if="compareData.noneCodingDefectCom > 0" class="el-icon-top top"></i><i
                            v-if="compareData.noneCodingDefectCom < 0" class="el-icon-bottom bottom"></i>{{Math.abs(getZeroTwoNum(compareData.noneCodingDefectCom * 100))}}%
                                </span></p></div>
                </div>
                <div class="item">
                    <p>主要诊断缺陷病案数</p>
                    <p :class="{pointer: compareData.firstMainDiagnosis}" @click="toEffectList(false, 8)">{{compareData.firstMainDiagnosis}}</p>
                    <div><p :class="{pointer: compareData.lastMainDiagnosis}" @click="toEffectList(true, 8)">{{compareData.lastMainDiagnosis}}
                        <span v-if="compareData.mainDiagnosisCom !== null"
                              :class="{'tooltips-red': compareData.mainDiagnosisCom > 0, 'tooltips-blue': compareData.mainDiagnosisCom < 0}">
                                    <i v-if="compareData.mainDiagnosisCom > 0" class="el-icon-top top"></i><i
                            v-if="compareData.mainDiagnosisCom < 0" class="el-icon-bottom bottom"></i>{{Math.abs(getZeroTwoNum(compareData.mainDiagnosisCom * 100))}}%
                                </span></p></div>
                </div>
                <div class="item">
                    <p>主要手术缺陷病案数</p>
                    <p :class="{pointer: compareData.firstMainSurgery}" @click="toEffectList(false, 10)">{{compareData.firstMainSurgery}}</p>
                    <div><p :class="{pointer: compareData.lastMainSurgery}" @click="toEffectList(true, 10)">{{compareData.lastMainSurgery}}
                        <span v-if="compareData.mainSurgeryCom !== null"
                              :class="{'tooltips-red': compareData.mainSurgeryCom > 0, 'tooltips-blue': compareData.mainSurgeryCom < 0}">
                                    <i v-if="compareData.mainSurgeryCom > 0" class="el-icon-top top"></i><i
                            v-if="compareData.mainSurgeryCom < 0" class="el-icon-bottom bottom"></i>{{Math.abs(getZeroTwoNum(compareData.mainSurgeryCom * 100))}}%
                                </span></p></div>
                </div>
            </div>
        </div>
        <div class="qc-table">
            <h3>修改病案列表</h3>
            <div class="qc-search">
                <el-form :inline="true" ref="QCForm" :model="QCForm">
                    <el-form-item label="住院医师：">
                        <el-select v-model="QCForm.resident" class="qc-select" filterable size="small" placeholder="请选择">
                            <el-option label="全部" :value="null"></el-option>
                            <el-option v-for="item in doctorList" :label="item.label" :value="item.label" :key="item.label.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="编码员：">
                        <el-select v-model="QCForm.coder" class="qc-select" filterable size="small" placeholder="请选择">
                            <el-option label="全部" :value="null"></el-option>
                            <el-option v-for="item in coderList" :label="item.label" :value="item.label" :key="item.label.value"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="末次修改人：">
                        <el-select v-model="QCForm.editor" class="qc-select" filterable size="small" placeholder="请选择">
                            <el-option label="全部" :value="null"></el-option>
                            <el-option v-for="item in editorList" :label="item.userName" :value="item.userName" :key="item.userId"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="修改类别：">
                        <el-select v-model="QCForm.codeKind" class="qc-select-class" filterable size="small" placeholder="请选择">
                            <el-option label="全部" :value="null"></el-option>
                            <el-option label="主要诊断修改" :value="1"></el-option>
                            <el-option label="主要手术操作修改" :value="2"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="审核状态：">
                        <el-select v-model="QCForm.checkState" class="qc-select" filterable size="small" placeholder="请选择">
                            <el-option label="全部" :value="null"></el-option>
                            <el-option label="已审核" :value="1"></el-option>
                            <el-option label="驳回" :value="2"></el-option>
                            <el-option label="未审核" :value="0"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="检索：">
                        <el-input v-model="QCForm.keyword" class="qc-input" size="small" placeholder="请输入病案号/患者姓名"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" size="small" @click="changePage">查询</el-button>
                    </el-form-item>
                    <el-form-item style="float: right">
                        <el-button type="primary" size="small" v-auth="{code: 100003000004}" @click="toExport">导出</el-button>
                    </el-form-item>
                </el-form>
                <el-table
                    ref="tableData"
                    :data="tableData"
                    tooltip-effect="light"
                    border
                    @sort-change="sortChange"
                    class="data-table">
                    <el-table-column
                        label="序号"
                        type="index"
                        align="center"
                        width="40">
                    </el-table-column>
                    <el-table-column
                        prop="medicalRecordSign"
                        label="病案号"
                        min-width="90"
                        sortable="custom"
                        align="center"
                        show-overflow-tooltip>
                        <template slot-scope="scope">
                        <span class="to-child-page" :class="viewInfoMonth(scope.row.dischargeDate) ? '' : 'disabled'"
                              @click="toInfo(scope.row, scope.$index)">{{scope.row.medicalRecordSign}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="hospitalTime"
                        label="住院次数"
                        min-width="80"
                        sortable="custom"
                        align="center"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column
                        label="患者姓名"
                        align="center"
                        prop="patientName"
                        sortable="custom"
                        min-width="85">
                    </el-table-column>
                    <el-table-column
                        prop="departmentName"
                        label="出院科室"
                        align="center"
                        min-width="110"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column
                        prop="dischargeDate"
                        label="出院日期"
                        align="center"
                        sortable="custom"
                        min-width="85"
                        show-overflow-tooltip>
                        <template slot-scope="scope">
                            {{scope.row.dischargeDate.substring(0, 10)}}
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="noneCoding"
                        label="非编码项修改"
                        sortable="custom"
                        align="center"
                        min-width="120"
                        show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span v-if="scope.row.noneCoding > 0" class="to-child-page" @click="toEditList(scope.row)">{{scope.row.noneCoding}}</span>
                            <span v-else>{{scope.row.noneCoding}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="coding"
                        label="编码项修改"
                        sortable="custom"
                        align="center"
                        min-width="110"
                        show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span v-if="scope.row.coding > 0" class="to-child-page" @click="toEditList(scope.row, 'code')">{{scope.row.coding}}</span>
                            <span v-else>{{scope.row.coding}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="mainDiagnosis"
                        label="主要诊断修改"
                        align="center"
                        sortable="custom"
                        min-width="130"
                        show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span v-if="scope.row.mainDiagnosis > 0">有</span>
                            <span v-else>无</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="mainSurgery"
                        label="主要手术操作修改"
                        sortable="custom"
                        align="center"
                        min-width="160"
                        show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span v-if="scope.row.mainSurgery > 0">有</span>
                            <span v-else>无</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="resident"
                        label="住院医师"
                        sortable="custom"
                        align="center"
                        min-width="110"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column
                        prop="coder"
                        label="编码员"
                        sortable="custom"
                        align="center"
                        min-width="80"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column
                        prop="status"
                        label="审核状态"
                        align="center"
                        sortable="custom"
                        min-width="85"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column
                        prop="editor"
                        label="末次修改人"
                        align="center"
                        sortable="custom"
                        min-width="100"
                        show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column
                        prop="modifiedDate"
                        label="末次修改时间"
                        align="center"
                        sortable="custom"
                        min-width="140"
                        show-overflow-tooltip>
                    </el-table-column>
                </el-table>
                <pagination v-show="tableData.length > 0" :total="total" :page.sync="currentPage" :limit.sync="pageSize"
                            @pagination="changePage"/>
            </div>
        </div>
    </div>
</template>

<script>
    import {getQCOverview, getQCCompare, getModifiedList} from '@/api/qc-effect/index'
    import {getZeroTwoNum, getSortString, viewInfoMonth} from '@/utils/filters'
    import OverviewEchart from '@/components/OverviewEchart'
    import OverviewCard from '@/components/OverviewCard'
    import {getLastUserList} from '@/api/global/index'
    import Pagination from '@/components/Pagination'
    import FileSaver from 'file-saver'
    import ExcelJS from 'exceljs'

    export default {
        name: 'index',
        data () {
            return {
                // 配置echart卡片参数
                initCardParams: {
                    width: 'calc(58% - 10px)',
                    height: '530px',
                    type: 'line'
                },
                // echart数据
                echartData: [],
                // 卡片名称
                cardName: {
                    cardList: '质控效果总览'
                },
                cardData: [],
                // 编码和非编码缺陷选择
                radio: 0,
                // 编码错误数据总数
                totalError: 0,
                // 非编码错误数据总数
                totalNonError: 0,
                // 进度条数据
                top10List: [],
                // 实际使用数据/进度条
                realList: [],
                // 图表显示文字
                showText: {
                    codingError: 0,
                    noCodingError: 0
                },
                // 修改对比
                compareData: {
                    firstNationAvgScore: 0,
                    firstDefect: 0,
                    firstCodingDefect: 0,
                    firstNoneCodingDefect: 0,
                    firstMainDiagnosis: 0,
                    firstMainSurgery: 0,
                    lastNationAvgScore: 0,
                    lastDefect: 0,
                    lastCodingDefect: 0,
                    lastNoneCodingDefect: 0,
                    lastMainDiagnosis: 0,
                    lastMainSurgery: 0,
                    nationAvgScoreCom: 0,
                    defectCom: 0,
                    codingDefectCom: 0,
                    noneCodingDefectCom: 0,
                    mainDiagnosisCom: 0,
                    mainSurgeryCom: 0
                },
                // 修改列表查询字段
                QCForm: {
                    codeKind: null,
                    checkState: null,
                    resident: null,
                    editor: null,
                    coder: null,
                    keyword: ''
                },
                // 表格数据
                tableData: [],
                // 排序字段
                sortMap: {},
                // 数据总数
                total: 0,
                // 当前页
                currentPage: 1,
                // 每页数量
                pageSize: 20,
                // 全局搜索内容，用于翻页等不传参时使用数据
                globalForm: {},
                // 使用储存的数据，不去请求
                useStoreOverview: false,
                useStoreTop10: false,
                useStoreTrend: false,
                // 医师下拉
                doctorList: [],
                // 编码员下拉
                coderList: [],
                // 最后修改人下拉
                editorList: [],
                // 导出的全部数据
                allexportData: []
            }
        },
        created () {
            // tags判断入口是否从选项卡进入
            this.useStoreOverview = this.$route.query.tags === 'tags'
            this.useStoreTop10 = this.$route.query.tags === 'tags'
            this.useStoreTrend = this.$route.query.tags === 'tags'
            this.initPage()
        },
        methods: {
            getZeroTwoNum,
            viewInfoMonth,
            /**
             * 初始化页面参数
             */
            initPage () {
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                if (query) {
                    this.QCForm.codeKind = query.codeKind
                    this.QCForm.checkState = query.checkState
                    this.QCForm.resident = query.resident
                    this.QCForm.editor = query.editor
                    this.QCForm.coder = query.coder
                    this.QCForm.keyword = query.keyword
                    this.currentPage = query.pageIndex || 1
                    this.pageSize = query.pageSize || 20
                    this.sortType = query.orderBy
                }
            },
            changeCoderList (list) {
                this.coderList = list
                this.getLastUser()
            },
            changeDoctorList (list) {
                this.doctorList = list
            },
            /**
             * 获取最后修改人
             */
            getLastUser () {
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                let params = {
                    orgId: query.orgId
                }
                getLastUserList(params).then(res => {
                    if (res.code.toString() === '200') {
                        this.editorList = res.data
                    }
                })
            },
            /**
             * 提交查询
             * @param form 筛选条件
             */
            submitSearch (form) {
                let data = form || this.globalForm
                this.globalForm = data
                let params = {
                    start: data.start,
                    end: data.end,
                    orgId: data.orgId,
                    department: data.department,
                    departmentName: data.departmentName,
                    coder: data.coder
                }
                this.setGetStore(this.$route.name, params)
                this.getDataOverview(params)
                this.getCompare(params)
                this.getEditTable(params)
            },
            /**
             * 获取总览
             * @param data 请求参数
             */
            getDataOverview (data) {
                if (this.getSession(this.$route.name, 'getQCOverview') && this.useStoreOverview) {
                    this.useStoreOverview = false
                    let res = this.getSession(this.$route.name, 'getQCOverview')
                    if (res.code.toString() === '200') {
                        // 顶部卡片数据
                        this.cardData = [
                            {
                                name: '总病案数',
                                unit: '例',
                                tipsUnit: '%',
                                number: res.data.total,
                                intuitive: getZeroTwoNum(res.data.totalCom * 100),
                                urlName: 'QCEffectMRList',
                                defectSate: 0
                            }, {
                                name: '总修改病案数',
                                unit: '例',
                                tipsUnit: '%',
                                number: res.data.modified,
                                intuitive: getZeroTwoNum(res.data.modifiedCom * 100)
                            }, {
                                name: '修改编码缺陷',
                                unit: '例',
                                number: res.data.codingModified
                            }, {
                                name: '修改非编码缺陷',
                                unit: '例',
                                number: res.data.noneCodingModified
                            }
                        ]
                    }
                } else {
                    getQCOverview(data).then(res => {
                        this.useStoreOverview = false
                        this.setSession(this.$route.name, {getQCOverview: res})
                        if (res.code.toString() === '200') {
                            // 顶部卡片数据
                            this.cardData = [
                                {
                                    name: '总病案数',
                                    unit: '例',
                                    tipsUnit: '%',
                                    number: res.data.total,
                                    intuitive: getZeroTwoNum(res.data.totalCom * 100),
                                    urlName: 'QCEffectMRList',
                                    defectSate: 0
                                }, {
                                    name: '总修改病案数',
                                    unit: '例',
                                    tipsUnit: '%',
                                    number: res.data.modified,
                                    intuitive: getZeroTwoNum(res.data.modifiedCom * 100)
                                }, {
                                    name: '修改编码缺陷',
                                    unit: '例',
                                    number: res.data.codingModified
                                }, {
                                    name: '修改非编码缺陷',
                                    unit: '例',
                                    number: res.data.noneCodingModified
                                }
                            ]
                        } else {
                            this.$message.error(res.message)
                        }
                    })
                }
            },
            /**
             * 导出质控评分数据列表
             */
            toExport () {
                let params = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                if (!params.orderBy) params.orderBy = '`DischargeDate` desc'
                this.$store.dispatch('UpdateLoadingText', '0%')
                this.$store.dispatch('UpdateIsExport', true)
                this.$store.dispatch('UpdateLoading', true)
                params.pageIndex = 1
                params.pageSize = 1000
                this.allexportData = []
                this.sendRequest(params)
            },
            /**
             * 发送请求
             * @param params 请求参数
             */
            sendRequest (params) {
                let allIndex = Math.ceil(this.total / 1000)
                getModifiedList(params).then(res => {
                    if (res.code.toString() === '200') {
                        this.$store.dispatch('UpdateLoadingText', parseInt(params.pageIndex / allIndex * 95) + '%')
                        this.allexportData = this.allexportData.concat(res.data.rows)
                        if (params.pageIndex < allIndex) {
                            this.sendRequest({...params, pageIndex: params.pageIndex + 1})
                        } else {
                            this.exportDataList('修改病案列表', this.allexportData)
                        }
                    } else {
                        this.$store.dispatch('UpdateIsExport', false)
                        this.$store.dispatch('UpdateLoading', false)
                        this.$message.error('导出失败')
                    }
                }).catch(() => {
                    this.$store.dispatch('UpdateIsExport', false)
                    this.$store.dispatch('UpdateLoading', false)
                    this.$message.error('导出失败')
                })
            },
            /**
             * 导出excel表头
             */
            getHeader () {
                return [{
                    header: '序号', key: 'index', width: 10
                }, {
                    header: '病案号', key: 'medicalRecordSign', width: 12
                }, {
                    header: '住院次数', key: 'hospitalTime', width: 10
                }, {
                    header: '患者姓名', key: 'patientName', width: 12
                }, {
                    header: '出院科室', key: 'departmentName', width: 16
                }, {
                    header: '出院日期', key: 'dischargeDate', width: 16
                }, {
                    header: '非编码项修改', key: 'noneCoding', width: 16
                }, {
                    header: '编码项修改', key: 'coding', width: 16
                }, {
                    header: '主要诊断修改', key: 'mainDiagnosis', width: 16
                }, {
                    header: '主要手术操作修改', key: 'mainSurgery', width: 16
                }, {
                    header: '住院医师', key: 'resident', width: 12
                }, {
                    header: '编码员', key: 'coder', width: 12
                }, {
                    header: '审核状态', key: 'status', width: 16
                }, {
                    header: '末次修改人', key: 'editor', width: 12
                }, {
                    header: '末次修改时间', key: 'modifiedDate', width: 24
                }]
            },
            /**
             * 导出列表excel
             */
            exportDataList (name, data) {
                let workbook = new ExcelJS.Workbook()
                workbook.creator = 'lyliang'
                workbook.views = [{
                    x: 0,
                    y: 0,
                    firstSheet: 0,
                    activeTab: 1,
                    visibility: 'visible'
                }]
                let worksheet = workbook.addWorksheet('Sheet1')
                worksheet.columns = this.getHeader()
                for (let i = 0; i < data.length; i++) {
                    data[i].index = i + 1
                    data[i].dischargeDate = data[i].dischargeDate.substring(0, 10)
                    data[i].mainDiagnosis = data[i].mainDiagnosis > 0 ? '有' : '无'
                    data[i].mainSurgery = data[i].mainSurgery > 0 ? '有' : '无'
                    worksheet.addRow(data[i])
                    worksheet.getRow(i + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                    let rate = parseInt((i + 1) / data.length * 0.03 * 100 + 95) + '%'
                    this.$store.dispatch('UpdateLoadingText', rate)
                }
                worksheet.getRow(data.length + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                workbook.xlsx.writeBuffer().then(data => {
                    this.$store.dispatch('UpdateLoadingText', '99%')
                    let blob = new Blob([data], {type: 'EXCEL_TYPE'})
                    FileSaver.saveAs(blob, `${this.parseTime(new Date().getTime())} ${name}.xlsx`)
                    this.$store.dispatch('UpdateLoadingText', '100%')
                    this.$store.dispatch('UpdateIsExport', false)
                    this.$store.dispatch('UpdateLoading', false)
                })
            },
            /**
             * 获取对比
             * @param data 请求参数
             */
            getCompare (data) {
                if (this.getSession(this.$route.name, 'getQCCompare') && this.useStoreOverview) {
                    this.useStoreOverview = false
                    let res = this.getSession(this.$route.name, 'getQCCompare')
                    if (res.code.toString() === '200') {
                        this.compareData = res.data
                    }
                } else {
                    getQCCompare(data).then(res => {
                        this.useStoreOverview = false
                        this.setSession(this.$route.name, {getQCCompare: res})
                        if (res.code.toString() === '200') {
                            this.compareData = res.data
                        } else {
                            this.$message.error(res.message)
                        }
                    })
                }
            },
            /**
             * 翻页
             */
            changePage () {
                this.getEditTable(this.globalForm)
            },
            /**
             * 获取表格
             * @param data 请求参数
             */
            getEditTable (data) {
                data = {
                    ...data,
                    ...this.QCForm,
                    pageSize: this.pageSize,
                    pageIndex: this.currentPage,
                    orderBy: this.sortType
                }
                if (!data.orderBy) data.orderBy = '`DischargeDate` desc'
                this.setGetStore(this.$route.name, data)
                if (this.getSession(this.$route.name, 'getModifiedList') && this.useStoreOverview) {
                    this.useStoreOverview = false
                    let res = this.getSession(this.$route.name, 'getModifiedList')
                    if (res.code.toString() === '200') {
                        this.tableData = res.data.rows
                        this.sortMap = res.data.maps
                        this.total = res.data.total
                    }
                } else {
                    getModifiedList(data).then(res => {
                        this.useStoreOverview = false
                        this.setSession(this.$route.name, {getModifiedList: res})
                        if (res.code.toString() === '200') {
                            this.tableData = res.data.rows
                            this.sortMap = res.data.maps
                            this.total = res.data.total
                        } else {
                            this.$message.error(res.message)
                        }
                    })
                }
            },
            /**
             * 排序修改
             * @param colData.prop 排序参数
             * @param colData.order 正序倒序 ascending 升序 descending 降序 null 不排序默认
             */
            sortChange (colData) {
                this.sortType = getSortString(colData, this.sortMap)
                this.tableData = []
                this.currentPage = 1
                this.changePage()
            },
            /**
             * 切换单选改变数据
             */
            changeList () {
                this.realList = this.radio ? this.top10List.noneCoding : this.top10List.coding
                this.total = this.radio ? this.totalNonError : this.totalError
            },
            /**
             * 设置右侧显示文字
             * @param percentage 当前进度
             */
            progressFormat (percentage) {
                return Math.round(percentage * this.total / 100) + '例'
            },
            /**
             * 下钻修改项详情
             * @param row 行数据
             * @param type code编码
             */
            toEditList (row, type) {
                let params = {
                    medicalRecordID: row.medicalRecordID,
                    departmentName: row.departmentName,
                    medicalRecordSign: row.medicalRecordSign,
                    hospitalTime: row.hospitalTime,
                    dischargeDate: row.dischargeDate,
                    resident: row.resident,
                    coder: row.coder
                }
                if (type === 'code') {
                    this.$store.dispatch('search/coverSearchFormItem', {
                        pageName: 'QCEffectCode',
                        query: params
                    })
                    this.$router.push({name: 'QCEffectCode'})
                } else {
                    this.$store.dispatch('search/coverSearchFormItem', {
                        pageName: 'QCEffectNonCode',
                        query: params
                    })
                    this.$router.push({name: 'QCEffectNonCode'})
                }
            },
            /**
             * 前往病案详情
             * @param row 行数据
             * @param index 索引
             */
            toInfo (row, index) {
                let data = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                if (viewInfoMonth(row.dischargeDate)) {
                    let params = {
                        ...data,
                        pageIndex: (this.currentPage - 1) * this.pageSize + index + 1,
                        pageSize: 1,
                        isLast: true
                    }
                    this.$store.dispatch('search/coverSearchFormItem', {
                        pageName: 'QCEffectInfo',
                        query: params
                    })
                    this.$router.push({name: 'QCEffectInfo'})
                }
            },
            /**
             * 去病案首页列表
             * @param isLast 首末次
             * @param type 缺陷类型
             */
            toEffectList (isLast, type) {
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                let params = {
                    ...query,
                    isLast: isLast,
                    defectSate: type,
                    pageIndex: 1
                }
                this.$store.dispatch('search/coverSearchFormItem', {
                    pageName: 'QCEffectMRList',
                    query: params
                })
                this.$router.push({name: 'QCEffectMRList'})
            }
        },
        components: {
            OverviewCard,
            OverviewEchart,
            Pagination
        }
    }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
    .quality-overview-container {
        .compare-table {
            padding: 0 10px 10px;
            background: #fff;
            h3 {
                font-size: 16px;
                color: #000;
                font-weight: 600;
                line-height: 48px;
            }
            .content {
                display: flex;
                justify-content: space-between;
                align-items: flex-start;
                position: relative;
                .line {
                    position: absolute;
                    width: 100%;
                    height: 1px;
                    background: #f0f0f0;
                    left: 0;
                    top: 40px;
                    &:nth-child(2) {
                        top: 80px;
                    }
                    &:nth-child(3) {
                        top: 120px;
                    }
                }
                .item {
                    .pointer {
                        color: #409EFF;
                        cursor: pointer;
                    }
                    & > p {
                        margin: 0;
                        text-align: center;
                        line-height: 40px;
                        font-size: 20px;
                        color: #000;
                        &:first-child {
                            color: #333;
                            font-size: 14px;
                        }
                    }
                    &:nth-child(4) {
                        p {
                            text-align: left;
                            font-size: 14px;
                            color: #797979;
                        }
                    }
                    &:last-child {
                        margin-right: 80px;
                    }
                    div {
                        display: flex;
                        justify-content: center;
                        p {
                            display: inline-block;
                            margin: 0;
                            text-align: center;
                            line-height: 40px;
                            font-size: 20px;
                            color: #000;
                            position: relative;
                            span {
                                position: absolute;
                                right: -70px;
                                top: 0;
                                font-size: 14px;
                            }
                        }
                    }
                }
            }
        }
        .qc-table {
            padding: 0 10px 10px;
            min-height: 430px;
            background: #fff;
            h3 {
                font-size: 16px;
                color: #000;
                font-weight: 600;
                line-height: 48px;
            }
            .qc-search {
                .el-form-item {
                    margin-bottom: 10px;
                }
                .qc-select-class {
                    width: 156px;
                }
                .qc-select {
                    width: 100px;
                }
                .qc-input {
                    width: 170px;
                }
            }
        }
    }
</style>
